package com.vstudy.zx.dao.provider;

import com.vstudy.zx.entity.Teacher;
import org.apache.ibatis.jdbc.SQL;

public class TeacherDaoProvider {
    public String update(Teacher teacher) {
        String sql = new SQL() {{
            UPDATE("tb_teacher");
            if (teacher.getTe_name() != null) {
                SET("te_name=#{te_name}");
            }
            if (teacher.getTe_login_name() != null) {
                SET("te_login_name=#{te_login_name}");
            }
            if (teacher.getTe_password() != null) {
                SET("te_password=#{te_password}");
            }
            if (teacher.getTe_gender() != null) {
                SET("te_gender=#{te_gender}");
            }
            if (teacher.getTe_age() != null) {
                SET("te_age=#{te_age}");
            }
            if (teacher.getSubject() != null) {
                SET("subject_id=#{subject.subject_id}");
            }
            if (teacher.getSchool() != null) {
                SET("school_id=#{school.school_id}");
            }
            WHERE("te_id=#{te_id}");
        }}.toString();
        return sql;
    }
}
